/*
 * Copyright (c) 2010 Zauber S.A.  -- All rights reserved
 */
package ar.edu.itba.ia2010.geneticos.motor.api.sintaxistree.generators;

import java.util.Random;

import ar.edu.itba.ia2010.geneticos.motor.api.sintaxistree.Expresion;
import ar.edu.itba.ia2010.geneticos.motor.api.sintaxistree.ExpresionGenerator;
import ar.edu.itba.ia2010.geneticos.motor.api.sintaxistree.impl.ExpresionPrimitive;

/**
 * Implementa la inicializacion "Grow".
 * 
 * @author Juan F. Codagnone
 * @since Mar 28, 2010
 */
public class GrowExpresionGenerator extends AbstractExpresionGenerator {
    
    /** Creates the FullExpresionGenerator. */
    public GrowExpresionGenerator(final ExpresionPrimitive []primitives) {
        super(primitives);
    }
    
    /** @see ExpresionGenerator#generate(Random, int) */
    public final Expresion generate(final Random random, final int maxDepth) {
      Expresion ret;
      if(maxDepth <= 0) {
          ret = nextTerminal(random, maxDepth);
      } else {
          ret = next(random, maxDepth); 
      }
      return ret;        
  }
}
